<?php

class Com_blog{
	
	public $defaultAct='index';
	function __construct($ainfo=null){
		$this->model = Afun_db()->model(Acan_table_blog);
		$this->blog_cg = Afun_db()->model(Acan_table_blog_cg);
	}
	
	function cglist(){
		$cgdata = Afun_cache_get('com_blog_cgdata');
		if(empty($cgdata)){
			$con->select = "a.*,(SELECT count(b.see) FROM `".Acan_table_blog."` b where a.cg = b.cg and b.see=0) as count";
			$cgdata = $this->blog_cg->findAll($con);
			Afun_cache_set('com_blog_cgdata',$cgdata,300);//写入缓存
		}
		return $cgdata;
	}
	//搜索
	function search($limit='3'){
		$search = $this->id;
		$con->where .= "a.if_auth=1 ";
		if($search){
			$con->where .= "and (a.`title` LIKE '%$search%' or a.`note` LIKE '%$search%') ";
		}
		$page->page = $limit;
		$page->order = "time_up DESC";
		return Afun_new('data',Acan_table_note)->datas($con,$page);
	}
	
}

?>